package com.itheima.health.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.health.pojo.Order;
import com.itheima.health.pojo.OrderSetting;
import org.apache.ibatis.annotations.Select;

import java.util.Map;

public interface OrderMapper extends BaseMapper<Order> {
    @Select("select * from t_ordersetting where ORDERDATE = #{orderDate}")
    OrderSetting findOrderSettingByOrderDate(String orderDate);

    @Select("select count(1) from t_order where ORDERDATE=#{orderDate} and MEMBER_ID = #{id} and SETMEAL_ID = #{setmealId}")
    int haveOrderOrNot(Integer id, int setmealId, String orderDate);

    @Select("select ts.name as setmeal,tm.name as member,tor.ORDERDATE as orderDate,tor.ORDERTYPE as orderType " +
            "from t_order tor , t_member tm , t_setmeal ts " +
            "where tor.MEMBER_ID = tm.ID and tor.SETMEAL_ID=ts.ID " +
            "and tor.ID=#{id}")
    Map findById(int id);
}
